import { userLogin } from '@/api/profile'
export default {
  // 命名空间
  namespaced: true,
  state: {
    profile: null,
    token: ''
  },
  getters: {},
  mutations: {
    setProfile(state, payload) {
      state.profile = { ...state.profile, ...payload }
    },
    setToken(state, payload) {
      state.token = payload
      uni.setStorageSync('userToken', payload)
    }
  },
  actions: {
    async login(content, phoneNumber) {
      let res = await userLogin(phoneNumber)
      content.commit('setProfile', res.result)
      content.commit('setToken', res.result.token)
    }
  },
};
